<?php

session_start();

require_once($_SERVER['DOCUMENT_ROOT'].'/incofarming/Functions/config.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/incofarming/Functions/class/produk_model.php');

$produk_model = new Produk_model();

$id_user = $_SESSION['id_user'];
$id_kop = $_SESSION['id_kop'];

$prod_res = $produk_model->get_produk_data($id_kop);
if(mysql_num_rows($prod_res) > 0){
	$prod_arr = array();
	while($row = mysql_fetch_array($prod_res)){
		
		$besaran = mysql_fetch_array($koperasi_model->get_besaran($row['IDBESARAN']));
		
		if($row['KETERSEDIAAN'] == 1) $ava = "Tersedia";
		else $ava = "Tidak tersedia";
		
		$foto_res = $koperasi_model->get_foto($row['IDFOTO']);
		$foto = mysql_fetch_array($foto_res);
		
		$temp = array(
			'id_produk' => $row['IDPRODUK'],
			'nama_prod' => $row['NAMAPRODUK'],
			'harga_sat' => $row['HARGASAT'],
			'ava' => $ava,
			'besaran' => $besaran['BESARAN'],
			'foto' => $foto['IDFOTO']
		);
		
		$prod_arr[] = $temp;
	}
}

include($_SERVER['DOCUMENT_ROOT'].'/incofarming/Views/produk/produk_view.php');

?>